import { createApp } from 'vue'
import router from './_find/router'
import ElementPlus from './_find/element-plus'
import '../style/basic.scss'
import './style.scss'
import App from './App.vue'
import IconSvg from '../svg-icons'
import GlobalComponents from './_find/components/global'
import pinia from './_find/store'
import useApp from './_find/store/app'
import '@xuekl/lib-flexible'
import { getToken } from '~/utils'



const app = createApp(App)
const appStore = useApp(pinia)
app.use(IconSvg)
app.use(ElementPlus)
app.use(GlobalComponents);


// 处理动态路由刷新页面白屏问题
(async function () {
    if (getToken()) {
        await appStore.initUserInfo()
        await appStore.initRouters()
        setTimeout(() => { app.use(router).mount('#app') }, 0)
    } else {
        app.use(router).mount('#app')
    }
})()
